/* File:       wifi.h
* Function:    supply the wifii moudle function
* Creator:     LDM
* Data:        2009.05.07
* status:      create
* History:
*/

#ifndef _WIFI_H
#define _WIFI_H

/******************************************************************************
*****************************head file included area***************************
******************************************************************************/

/******************************************************************************
****************************macro definition area******************************
******************************************************************************/
#define INTERFACE_COUNT		16
#define USER_CELL_COUNT		64
#define CELL_COUNT				128
#define NETWORK_SETUP_SCRIPT    "/etc/init.d/Snetwork"
#define NETWORK_CONFIG          "/etc/network/network.conf"

/******************************************************************************
***************************structure definition area***************************
******************************************************************************/
typedef enum 
{
    ENC_OFF = 0x00,
    ENC_OPEN,
    ENC_RESTRICTED
} t_encmode;
    
typedef enum
{
    MODE_MANAGED = 0x00,
    MODE_ADHOC
} t_wifimode;

typedef struct {
    int status;
    int quality;
    int level;
    int noise;
    
}iw_statics;

typedef struct _WIFI_CELL
{
    char address[32];
    char essid[128];
    char mode[16];
    t_encmode encmode;
    char channel[40];       
    char key[4];
    char userkey[128];
    char surpport_rates[128];
    char bit_rates[8];
    char quality[16];
    char signal_level[16];
    char noise_level[16];
    char state[128];
    char alias[128];
    int linkstate;
    
    //wpa variable
    unsigned int key_mgmt;
    
    //device type
    char device_type[16];
    
    //encryption type
    char encryption_type[16];
    
    unsigned int key_index;
}WIFI_CELL;

typedef struct _WIFI_INTERFACE{
	char name[16];
	char type[16];
	char essid[128];

    char encryption_type[16];

    t_wifimode mode;
	t_encmode encmode;
	char channel[4];
	char key[32];
	char quality[8];
	char key1[128];
	
	char address[32];
	char netmask[32];
	char broadcast[32];
	char gateway[32];
    
    gchar *nameserver[2];
	gboolean isdhcp;
	gboolean isstatic;
	/*for statistics data */
	gboolean UP;
	gboolean RUNNING;
	gboolean auto_dns;
        
    gboolean auto_active;  //add by shuai
        
	iw_statics stats;
	gboolean wifi_group_enable;
	WIFI_CELL wifi_group;
}WIFI_INTERFACE;

typedef struct _MY_WIFI
{
    int interface_index;
    int interface_count;
    WIFI_INTERFACE *wifi_interface[INTERFACE_COUNT];
    int cell_index;
    int cell_count;
    int user_cell_count;
    int user_cell_index;
    WIFI_CELL *wifi_cell[CELL_COUNT];
    WIFI_CELL *user_wifi_cell[USER_CELL_COUNT];
        
    GtkWidget* wifi_view;
    GtkWidget* wifi_combo;
    int cell_type;
}MY_WIFI;
    
    
typedef struct
{
    MY_WIFI *my_wifi;
    char Link_AP_MAC[48];
    GtkWidget *global_build_list;
    GtkWidget *mainwindow;
    GtkWidget *connect_window;
    GtkWidget *static_window;
    GtkTooltips *tooltips;
    gint connect_index;
    gint user_wifi_count;
    gboolean linkconnect;//if link layer is connect
    gchar *sel_key;
    int  key_mgmt;
    int key_index;
    gchar *type;
    gboolean RUNNING;
}NetWorkWifi;

/******************************************************************************
*********************************func declare area****************************
******************************************************************************/
gint show_wifi(NetWorkWifi *wifi);

#endif //_WIFI_H


